package com.menggudf.convert;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import org.springframework.stereotype.Component;

import com.menggudf.entity.AgeSelect;
import com.menggudf.entity.Illness;
import com.menggudf.entity.Symptom;
import com.menggudf.model.AgeSelectModel;
import com.menggudf.model.IllnessModel;
import com.menggudf.model.SymptomModel;

@Component
public class IllnessConvert {
    
    public IllnessModel entity2IllnessModelConvert(Illness ill){
        IllnessModel iModel = new IllnessModel();
        iModel.setId(ill.getId());
        iModel.setAuthor(ill.getAuthor());
        iModel.setCreateTime(ill.getCreateTime());
        iModel.setIllness(ill.getIllness());
        iModel.setLevelOneSubject(ill.getLevelOneSubject());
        iModel.setLevelTwoSubject(ill.getLevelTwoSubject());
        iModel.setModifyTime(ill.getModifyTime());
        iModel.setSex(ill.getSex());
        iModel.setAssistantExam(ill.getAssistantExam());
        iModel.setScheme(ill.getScheme());
        iModel.setDuration(ill.getDuration());
        iModel.setPathogen(ill.getPathogen());
        iModel.setMedicine(ill.getMedicine());
        iModel.setWarning(ill.getWarning());
        iModel.setLimitSymptoms(ill.getLimitSymptoms());
        iModel.setLimitNum(ill.getLimitNum());
        List<SymptomModel> yModels = new ArrayList<SymptomModel>();
        Set<Symptom> ss = ill.getSymptoms();
        for(Symptom s :ss ){
            SymptomModel sym = new SymptomModel();
            sym.setId(s.getId());
            sym.setSymptom(s.getSymptom());
            sym.setDegree(s.getDegree());
            sym.setMedicine(s.getMedicine());
            sym.setNature(s.getNature());
            sym.setTimes(s.getTimes());
            sym.setSdown(s.getSdown());
            sym.setSup(s.getSup());
            sym.setImgurl(s.getImgurl());
            sym.setParts(s.getParts());
            sym.setDescription(s.getDescription());
            
            sym.setHistorySort(s.getHistorySort());
            sym.setIncentive(s.getIncentive());
            sym.setIsImportant(s.getIsImportant());
            sym.setMedicineHistory(s.getMedicineHistory());
            sym.setPastHistory(s.getPastHistory());
            sym.setWarning(s.getWarning());
            sym.setLimitSymptoms(s.getLimitSymptoms());
            sym.setFactor(s.getFactor());
            yModels.add(sym);
        }
        iModel.setSymptoms(yModels);
        
/*        List<PartsModel> pModels = new ArrayList<PartsModel>();
        Set<Parts> pp = ill.getPartss();
        for(Parts p :pp ){
            PartsModel pModel = new PartsModel();
            pModel.setPart(p.getPart());
            pModel.setId(p.getId());
            pModels.add(pModel);
        }
        iModel.setPartss(pModels);*/
        
        List<AgeSelectModel> aModels = new ArrayList<AgeSelectModel>();
        Set<AgeSelect> aa = ill.getAges();
        for(AgeSelect a : aa){
            AgeSelectModel am = new AgeSelectModel();
            am.setAgeOption(a.getAgeOption());
            am.setId(a.getId());
            aModels.add(am);
        }
        iModel.setAges(aModels);
        return iModel;
        
    }

}
